package com.xiaren.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ShowLoginServlet
 */
@WebServlet("/ShowLoginServlet")
public class ShowLoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowLoginServlet() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.getCookies();
		String user = (String)request.getSession().getAttribute("user");
		response.getWriter().append("user = " + user);
		response.getWriter().append("\n");
		Cookie[] cookies = request.getCookies();
		for(Cookie cookie : cookies){
			response.getWriter().append("cookie.name = " + cookie.getName() + ", cookie.value = " + cookie.getValue() + "\n");
		}
	}

}
